package mainillnessname;


import java.util.ArrayList;

import com.example.animaldoctor03.R;

import Modle.disease.AnimalDiseaseCategorie;
import commonClass.ADAQueryAllAnimalDiseaseCategorieInfoByAnimalIDAction;
import commonClass.FunctionDispatcher;
import commonClass.RemoteActionsName;
import commonClass.FunctionDispatcher.IRequestCompeletListener;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class IllnessFZ extends Activity{

	private ListView listofIFZ = null;
	
	private String IDofillnessfz = "01371054603" ;
	private ArrayList<Object> resultListofIFZ = null;

	private void CSHofIFZ(){
		setContentView(R.layout.illnessfz);
		listofIFZ = (ListView)findViewById(R.id.listofIFZ);
	}
	
	private ArrayList<Object> assemblyofIFZ() {

		ArrayList<Object> list = new ArrayList<Object>();

		list.add(IDofillnessfz);
		return list;
	}
	
	private void bindingofIFZ(final ArrayList<Object> list){
		try{
		String resultofIFZ [] = new String [list.size()];
		for(int i = 0 ; i < list.size() ; i ++){
			
			resultofIFZ[i] =((AnimalDiseaseCategorie)list.get(i)).getAnimalDiseaseCategorieName();
		}
		ArrayAdapter<String> arrofIFZ  = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,resultofIFZ);
		listofIFZ.setAdapter(arrofIFZ);
		listofIFZ.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// TODO Auto-generated method stub
				AnimalDiseaseCategorie duixiangofIFZ = (AnimalDiseaseCategorie)list.get(position);
				Bundle bundleofIFZ = new Bundle();
				bundleofIFZ.putSerializable("shuju", duixiangofIFZ);
				Intent intentofIFZ = new Intent(IllnessFZ.this , IllnessNameDetails.class);
				intentofIFZ.putExtras(bundleofIFZ);
				startActivity(intentofIFZ);
				finish();
			}
		});
		}catch(NullPointerException e){
			Builder builderofINFZ = new AlertDialog.Builder(IllnessFZ.this);
			builderofINFZ.setMessage("无数据; 请用其他功能");
			builderofINFZ.create().show();
		}
		
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		CSHofIFZ();
		assemblyofIFZ();
		ArrayList<Object> parasListofIFZ = assemblyofIFZ();
		final ArrayList<Object> resultListTofIFZ = null;
		ADAQueryAllAnimalDiseaseCategorieInfoByAnimalIDAction iActionofIFZ = new ADAQueryAllAnimalDiseaseCategorieInfoByAnimalIDAction();
		FunctionDispatcher functionDispacherofIFZ = new FunctionDispatcher();
		try{
		functionDispacherofIFZ.exceute(RemoteActionsName.QueryAllAnimalDiseaseCategorieInfoByAnimalIDAction, parasListofIFZ, iActionofIFZ, new IRequestCompeletListener() {

			@Override
			public void doCompelet(ArrayList<Object> resultList) {
				// TODO Auto-generated method stub
		
				IllnessFZ.this.resultListofIFZ = resultList;
				bindingofIFZ(resultList);
			}
		},this);}catch(NullPointerException e){
			
			Builder builderofINFZf = new AlertDialog.Builder(IllnessFZ.this);
			builderofINFZf.setMessage("无返回值 ,请用其他功能");
			builderofINFZf.create().show();
		}

		

		
	
	}

}
